//
//  ST_PairsCenterPeculiaritySectionCell.swift
//  btvideo
//
//  Created by mac on 2020/1/10.
//  Copyright © 2020 JarvanZhang. All rights reserved.
//

import UIKit
import SnapKit
import SwifterSwift

//之前的版本
class ST_PairsCenterPeculiaritySectionCell: UITableViewCell {

    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
            
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        self.selectionStyle = .none
        contentView.backgroundColor = Color.white
        contentView.addSubview(icon_image_view)
        icon_image_view.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.width.height.equalTo(60)
            make.left.equalToSuperview().offset(15)
        }
        
        contentView.addSubview(peculiarityTextLabel)
        peculiarityTextLabel.snp.makeConstraints { (make) in
            make.left.equalTo(icon_image_view.snp.right).offset(10)
            make.top.equalTo(icon_image_view).offset(9)
        }
        
        contentView.addSubview(regimentation_label)
        regimentation_label.snp.makeConstraints { (make) in
            make.left.equalTo(icon_image_view.snp.right).offset(10)
            make.bottom.equalTo(icon_image_view).offset(-9)
        }
        
        contentView.addSubview(right_sign_view)
        right_sign_view.snp.makeConstraints { (make) in
            make.right.equalToSuperview().offset(-15)
            make.height.equalTo(30)
            make.width.equalTo(45+20)
            make.centerY.equalToSuperview()
        }
        
        right_sign_view.addSubview(right_sign_text_label)
        right_sign_text_label.snp.makeConstraints { (make) in
            make.right.equalToSuperview()
            make.centerY.equalToSuperview()
        }
        
        right_sign_view.addSubview(right_sign_corner_view)
        right_sign_corner_view.snp.makeConstraints { (make) in
            make.right.equalTo(right_sign_text_label.snp.left).offset(-5)
            make.centerY.equalToSuperview()
            make.width.height.equalTo(6)
        }
        
        
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
//        MARK:-Properties

    lazy var regimentation_label:UILabel = {
        let control = UILabel.init()
        
        control.textColor = Color.init(hexString: "#ACB4C0")
        control.font = UIFont.systemFont(ofSize: 14, weight: UIFont.Weight.regular)
        
        return control
    }()
    
    lazy var peculiarityTextLabel:UILabel = {
        let control = UILabel.init()
        
        control.textColor = Color.init(hexString: "#333333")
        control.font = UIFont.systemFont(ofSize: 16, weight: UIFont.Weight.semibold)
        
        return control
    }()

    lazy var icon_image_view:UIImageView = {
        let control = UIImageView()
        control.contentMode = UIView.ContentMode.scaleAspectFill
        control.cornerRadius = 10
        return control
    }()
    
    
    fileprivate lazy var right_sign_view:UIView = {
       let control = UIView()
        control.isHidden = true
        return control
    }()
    
    fileprivate lazy var right_sign_corner_view:UIView = {
       let control = UIView()
        control.backgroundColor = Color.init(hex: 0x42DAA3)
        control.cornerRadius = 3
        return control
    }()
    
    fileprivate lazy var right_sign_text_label:UILabel = {
       let control = UILabel()
        control.textColor = Color.init(hex: 0xACB4C0)
        control.text = "我符合！"
        control.font = UIFont.systemFont(ofSize: 12)
        return control
    }()
    
    
//    MARK:- Bind Model
    var model = ST_PairsPeculiarity(){
        didSet{
            
            icon_image_view.pin_setImage(from: model.image.compress_image().url, placeholderImage: ST_SwiftConst.shared.fetch_random_place_holder_image())
            
            peculiarityTextLabel.text = model.name
            regimentation_label.text = model.descriptionStr
            
            right_sign_view.isHidden = !model.is_conform
            
        }
    }
    
    
    
}
